//
//  HRDynamicBannerHeadView.m
//  Hear
//
//  Created by mac on 2017/7/25.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRDynamicBannerHeadView.h"
#import "SDCycleScrollView.h"
#import "HRDynamicBannerModel.h"
#import "HRFollowDynamicViewController.h"
#import "HRNoviceBootViewController.h"

@interface HRDynamicBannerHeadView ()<SDCycleScrollViewDelegate>
@property (nonatomic, strong)SDCycleScrollView *bannerScrollView;

@end
@implementation HRDynamicBannerHeadView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self){
        SDCycleScrollView *bannerScrollView = [[SDCycleScrollView alloc] initWithFrame:frame];
        [self addSubview:bannerScrollView];
        bannerScrollView.currentUserID = USERID;
        bannerScrollView.delegate = self;
        self.bannerScrollView = bannerScrollView;
        bannerScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
        bannerScrollView.placeholderImage = [UIImage imageNamed:@"默认加载图"];
    }
    return self;
}


-(void)setBannerArray:(NSArray *)bannerArray{
    _bannerArray = bannerArray;
    
    NSMutableArray *imageArr = [NSMutableArray array];
    for (HRDynamicBannerModel *model in bannerArray) {
        [imageArr addObject:model.ImgUrl];
    }
    self.bannerScrollView.imageURLStringsGroup = imageArr;
    
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    HRDynamicBannerModel *model = _bannerArray[index];
    
    if ([model.BannerType intValue] == 1){
        HRFollowDynamicViewController *dynamicVC = [HRFollowDynamicViewController new];
        dynamicVC.MomentTagCode = model.BannerValue;
        dynamicVC.dynamicType = TagListDynaimc;
        dynamicVC.MomentTagName = model.TitleName;
        [VIEWCCONTROLER.navigationController pushViewController:dynamicVC animated:YES];
    }else if ([model.BannerType intValue] == 2){
        HRNoviceBootViewController *boviceVC = [HRNoviceBootViewController new];
        boviceVC.title = model.TitleName;
        boviceVC.requestUrl = model.BannerValue;
        [VIEWCCONTROLER.navigationController pushViewController:boviceVC animated:YES];
    }
    
}

@end
